package es.cv.core;

import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.imgproc.Imgproc;

public class WatershedSegmenter {
	
	private Mat markers;
	
	public WatershedSegmenter(){
		this.markers = new Mat();
	}

	public void setMarkers(Mat markerImage) {
		markerImage.convertTo(markers, CvType.CV_32S);
	}

	public Mat process(Mat image) {
		Imgproc.watershed(image, markers);
		return markers;
	}
	
	public Mat getSegmentation(){
		Mat tmp = new Mat();
		markers.convertTo(tmp, CvType.CV_8U);
		return tmp;
	}
	
	public Mat getWaterSheds(){
		Mat tmp = new Mat();
		markers.convertTo(tmp, CvType.CV_8U, 255, 255);
		return tmp;
	}
}
